// 数字统计（数学+模拟）
#include <iostream>
using namespace std;
int main()
{
    int l, r;
    cin >> l >> r;
    int ret = 0;
    for (int i = l; i <= r; i++)
    {
        int tmp = i;
        while (tmp)
        {
            if (tmp % 10 == 2)
                ret++;
            tmp /= 10;
        }
    }
    cout << ret << endl;
    return 0;
}
// 两个数组的交集（哈希）
class Solution
{
    bool hash[1010] = {0};

public:
    vector<int> intersection(vector<int> &nums1, vector<int> &nums2)
    {
        vector<int> ret;
        for (auto x : nums1)
        {
            hash[x] = true;
        }
        for (auto x : nums2)
        {
            if (hash[x])
            {
                ret.push_back(x);
                hash[x] = false;
            }
        }
        return ret;
    }
};
// 点击消除（栈）
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s, st;
    cin >> s;
    for (auto ch : s)
    {
        if (st.size() && st.back() == ch)
            st.pop_back();
        else
            st += ch;
    }
    cout << (st.size() == 0 ? "0" : st) << endl;
    return 0;
}
// 数组中两个字符串的最⼩距离（模拟+贪⼼）
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    string s1, s2;
    string s;
    cin >> n;
    cin >> s1 >> s2;
    int prev1 = -1, prev2 = -1, ret = 0x3f3f3f3f;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == s1) // 去前⾯找最近的 s2
        {
            if (prev2 != -1)
            {
                ret = min(ret, i - prev2);
            }
            prev1 = i;
        }
        else if (s == s2) // 去前⾯找 s1
        {
            if (prev1 != -1)
            {
                ret = min(ret, i - prev1);
            }
            prev2 = i;
        }
    }
    if (ret == 0x3f3f3f3f)
        cout << -1 << endl;
    else
        cout << ret << endl;
    return 0;
}